home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1987 February / Ahoy_Magazine_87-02_1987_Double_L.d64 / digit decomp.128 (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  337b  |  16 lines

  1. 0 rem << cd38-5 >>
  2. 1 rem commodares problem #34-3
  3. 2 rem   digit decomposition
  4. 3 rem solution by
  5. 4 rem   wallace leeker
  6. 5 rem
  7. 10 input "number";x :if x>1e10 then 10
  8. 20 for a=1 to 9 : y=int(x/10)
  9. 30 n(a)=x-(y*10) : su=su+n(a) : x=y
  10. 40 next a : b=10
  11. 50 (NULL) : b=b-1 : (NULL) (NULL) n(b)>0
  12. 55 if b=1 then 80
  13. 60 (NULL) : print n(b)"+"; : b=b-1
  14. 70 (NULL) (NULL) b=1
  15. 80 print n(1)"=";su
  16.